import React from 'react';
import ReactDOM from 'react-dom';
import { Breadcrumb, Button } from 'antd';

const Demo = React.createClass({

  contextTypes: {
    router: React.PropTypes.object
  },

  getInitialState() {
    return {
      item: '出租管理'
    }
  },

  handleRouter() { 
    let path = this.props.location.pathname;
    let state = this.props.location.state;
    console.log(state);
    let lastPath = path.split('/')[path.split('/').length - 1];
    let index = '/landlord/rentManage/rentRooms/list';
    let goPathUrl = index;
    this.context.router.push({pathname: goPathUrl, state: {...state}});
  },

  render () {

    let path = this.props.location.pathname;
    console.log(path);
    let lastPath = path.split('/')[path.split('/').length - 1];
    let routerItem = {
      'list': '房间出租',
      'rentRooms': '房间出租',
      'history': '收租历史',
      'roomSets': '房间配置',
      'roomSetsUpdate': '修改房间配置',
      'collect': '收租',
    };
    let txtName = ( lastPath == 'list' || lastPath == 'rentRooms') ? '' : '返回';

    return (
      <div>
        <div className="nav-bar">
          <Breadcrumb separator="-" >
            <Breadcrumb.Item>出租管理</Breadcrumb.Item>
            <Breadcrumb.Item>{routerItem[lastPath]}</Breadcrumb.Item>
          </Breadcrumb>
          {
            ( lastPath == 'list' || lastPath == 'roomSetsUpdate' || lastPath == 'rentRooms') ? null : <Button className="ant-button" type="primary" onClick={this.handleRouter}>返回</Button>
          }
        </div>
        <div className="content-wrapper ">
          {this.props.children}
        </div>
      </div>
    );
  }
});

export default Demo